Skip to content

Conversation

@bfg
Copy link
Contributor

@bfg bfg commented Jun 7, 2017

This PR adds Retrofit2 async-http-client extras module.

Project Lombok is used to evade boilerplate.

@bfg bfg closed this Jun 8, 2017
@bfg bfg reopened this Jun 8, 2017
@bfg
Copy link
Contributor Author

bfg commented Jun 8, 2017

Seems like unrelated tests are failing.

  NettyReactiveStreamsTest>ReactiveStreamsTest.testConnectionDoesNotGetClosed:95 Invalid response byte at position 12000 expected [111] but found [45]

Tests run: 503, Failures: 2, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Asynchronous Http Client Project ................... SUCCESS [  0.864 s]
[INFO] Asynchronous Http Client Netty Utils ............... SUCCESS [  2.335 s]
[INFO] Asynchronous Http Client ........................... FAILURE [03:31 min]

@slandelle
Copy link
Contributor

slandelle commented Jun 8, 2017

This PR adds Retrofit2 async-http-client extras module.

Thanks! Being curious, why do you use AHC with Retrofit? I mean I would expect anyone going with Retrofit to go with the full Square stack and use OkHttp instead.

Project Lombok is used to evade boilerplate.

Correct me if I'm wrong, but such code generation causes stacktraces to not be aligned with source code lines, right? Also, my concern is that contributors might think this is code generation fiesta time, eg why not vavr (ex javaslang) or something else.
If possible, I'd rather go without it.

Seems like unrelated tests are failing.

Yeah, that's #1380.

private void throwAlreadyExecuted() {
throw new IllegalStateException("This call has already been executed.");
}
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing line feed

.request(request)
.build();
}
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing line feed

};
}

} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing line feed

return e -> {
};
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kill empty line

private void doThrow(String message) {
throw new RuntimeException(message);
}
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing line feed

.build();

// then
Assert.assertTrue(factory.getHttpClient() == httpClient);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Assert static imports

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use assertEquals (everywhere it makes sense)

httpClient.close();
}

@Test(enabled = false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are all the tests in this class disabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're using Github API, which is rate-limited and github may not be up all the time. Do you want me to convert this test so that it would start wiremock or similar webserver on local host and perform http calls against it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Please have a look at the org.asynchttpclient.testserver package. Then, we might need some maven build refactoring to the test jar is visible from extra modules.


<properties>
<retrofit2.version>2.3.0</retrofit2.version>
<lombok.version>1.16.16</lombok.version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'd rather not use lombok in there so coding style is consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can convert all the code to normal java code, but frankly i don't think it's worth it - some other open source projects, namely spring-cloud started using lombok 2-3 years ago and it seem to work for them very well.

So, do you want me to de-lombok the code?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can leave Lombok there. But I don't think it will ever make it into main module.

@bfg
Copy link
Contributor Author

bfg commented Jun 8, 2017

Thanks! Being curious, why do you use AHC with Retrofit? I mean I would expect anyone going
with Retrofit to go with the full Square stack and use OkHttp instead.

I find AHC most configurable http client in java world. I really like the idea of sharing single event loop group between differently configured AHC client instances, i really like it's non-blocking API and websocket support.

I don't find OKHttp as configurable and i really don't like it's async api.

But i really do like the idea of retrofit - and i would like to use proven http client engine beneath it.

Correct me if I'm wrong, but such code generation causes stacktraces to not be aligned with source
code lines, right? If so, I'm fine with using Lombock for this module, but it won't propagate to main one.

Lombok generates java code at compile time, so there is no runtime performance penalty. Stack trace line numbers may differ only with @Value annotated classes if @NonNull is being used on fields.

I use lombok daily and find it super-stable and useful. If you want me to remove lombok, that's fine with me, but i really don't think it's worth rejecting it.

@bfg
Copy link
Contributor Author

bfg commented Jun 12, 2017

Ok, @slandelle i've addressed all your code review comments and added the following functionality:

  • integration test suite now uses org.asynchttpclient.testserver test http server
  • Call and Call.Factory now allow multiple consumers to be attached for specific event types, allowing easy customization

Please review again. If you're okay with it, i will squash everything into one commit and resubmit.

@slandelle slandelle added this to the 2.1.0 milestone Jun 12, 2017
@slandelle slandelle merged commit ed1aa39 into AsyncHttpClient:master Jun 12, 2017
@slandelle
Copy link
Contributor

Thanks! Note that I fixed a NPE issue (see next commit).

Cheers!

@bfg bfg deleted the retrofit_integration branch June 12, 2017 14:31
@bfg
Copy link
Contributor Author

bfg commented Jun 12, 2017

Whoa! Thanks for cooperation! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants